




**************************Table 15*****************************************************
**************************Table 15*****************************************************
**************************Table 15*****************************************************

*----------------------------------------------------------

* Part I Columns 1-4: Labor Efficiency Gaps

*----------------------------------------------------------
cd "D:\Nanjing\2020\wage gap\Replication"
use "labor-basic-tpu-reg-1.dta",clear
*drop if export_intensity==1
gen ddd_export=did * d_export
* xtset newid t
 egen provyear=group(province  t)
 egen ind2year=group(ind2_adj  t)
 egen owneryear=group(QiuType  t)
 egen provowneryear=group(province QiuType  t)
 egen ind4year=group(ind4_adj  t)

capture drop ddd_export
gen indc_export=0
gen indc_export_new=0
replace indc_export=1 if export_intensity>0&(t==1999|t==2000|t==2001)
replace indc_export_new=1 if export_intensity>0&(t>=2001)

bysort newid: egen indc_export1=max(indc_export)
bysort newid: egen indc_export2=max(indc_export_new)

gen year1998=0
gen year1999=0
gen year2000=0
gen year2001=0
gen year2002=0
gen year2003=0
gen year2004=0
gen year2005=0
gen year2006=0
gen year2007=0
replace year1998=1 if t==1998
replace year2000=1 if t==2000
replace year1999=1 if t==1999
replace year2001=1 if t==2001
replace year2002=1 if t==2002
replace year2003=1 if t==2003
replace year2004=1 if t==2004
replace year2005=1 if t==2005
replace year2006=1 if t==2006
replace year2007=1 if t==2007

gen tpu1998=tpu_ind*year1998
gen tpu2000=tpu_ind*year2000
gen tpu1999=tpu_ind*year1999
gen tpu2001=tpu_ind*year2001
gen tpu2002=tpu_ind*year2002
gen tpu2003=tpu_ind*year2003
gen tpu2004=tpu_ind*year2004
gen tpu2005=tpu_ind*year2005
gen tpu2006=tpu_ind*year2006
gen tpu2007=tpu_ind*year2007
/*
bysort newid post: gen indc_n=_n==1
bysort newid: egen indc_exist=sum(indc_n)
*/

 

*egen ub1=pctile(absG),p(99)
*egen lb1=pctile(absG),p(1)

*replace did=0 if indc_export1==1
gen exp_post=indc_export1*post
gen exp_tpu=indc_export1*tpu
gen lnabsG_gdp=ln(absG_gdp)

winsor2 tfp_op lnabsG_gdp lnage  finance2  lnkL rate , replace cuts(1 99) trim
winsor2 lnRD, replace cuts(0 99) trim
drop if VMPL<0


*drop if indc_export1==0&export_intensity>0
*******************************************************************************************************
*15.1 column 1:  pre-expectation effect:
* add tpu*1999 and tpu*2000: if firm expected the TPU decrease, they these two terms will be negative and significant.
reghdfe lnabsG_gdp did tpu1999 tpu2000   Llnl  Ltfp_op   Llnage  LlnkL  LlnRD   export_intensity Lfinance2 ///
 Ltariff_input Ltariff_output post_kl_1998 Lhhi5_lns_ind Llnk_ind ,  ///
absorb(t newid ) cluster (ind4year)   
 
*********************************************************************************************************



*15.2 column 2: multiple year:
* add tpu*1999 and tpu*2000: if firm expected the TPU decrease, they these two terms will be negative and significant.
reghdfe lnabsG  tpu1999 tpu2000 tpu2001 tpu2002 tpu2003 tpu2004 tpu2005 tpu2006 tpu2007 ///
 Llnl Ltfp_op   Llnage  LlnkL LlnRD   export_intensity Lfinance2 ///
 Ltariff_input  Lhhi5_lns_ind Llnk_ind ,  ///
absorb(t newid) cluster (ind4year)   
 
*********************************************************************************************************
 
 *15.3 column 3:  pre-period
 
cd "D:\Nanjing\2020\wage gap\Replication"
use "labor-basic-tpu-reg-1.dta",clear
drop tpu_ind
capture drop _merge
keep if t<=2000
merge m:1 ind4_adj t using "tpu_ind98-00"
egen ind4year=group(ind4_adj  t)
replace tpu_ind=log(tpu_ind)

gen lnabsG_gdp=ln(absG_gdp)
replace LlnRD=Llnk_ind
winsor2 tfp_op lnabsG_gdp lnage  finance2  lnkL rate , replace cuts(1 99) trim
drop if VMPL<0
 
 reghdfe lnabsG_gdp   tpu_ind Llnl Ltfp_op   Llnage  LlnkL  LlnRD   export_intensity Lfinance2 ///
 Ltariff_input  Lhhi5_lns_ind ,  ///
absorb(t newid) cluster (ind4year)   

******************************************************************************************************

*15.4 column 4: random sample


cd "D:\Nanjing\2020\wage gap\Replication"

forvalue i=1/100{
use "labor-basic-tpu-reg-1.dta",clear
duplicates drop ind4_adj, force
egen median=pctile(tpu_ind),p(50)
gen tpu_indc=0
replace tpu_indc=1 if tpu_ind>median
gen obs_id=_n


gen random_digit=runiform()
sort random_digit
gen random_id=_n


*preserve
keep random_id tpu_indc ind4_adj
rename tpu_indc random_tpu
rename random_id  obs_id
replace random_tpu=1 if obs_id<=200
replace random_tpu=0 if obs_id>200

save "D:\Nanjing\2020\wage gap\Replication\mix\random_sample",replace
/*
restore
keep obs_id ind4_adj
save "D:\Nanjing\2020\wage gap\raw_sample",replace
*/






use "labor-basic-tpu-reg-1.dta",clear
merge m:1 ind4_adj using "D:\Nanjing\2020\wage gap\Replication\mix\random_sample"
egen ind4year=group(ind4_adj  t)
/*
drop if export_intensity==1
gen ddd_export=did * d_export
* xtset newid t
 egen provyear=group(province  t)
 egen ind2year=group(ind2_adj  t)
 egen owneryear=group(QiuType  t)
 egen provowneryear=group(province QiuType  t)
 egen ind4year=group(ind4_adj  t)

capture drop ddd_export
gen indc_export=0
gen indc_export_new=0
replace indc_export=1 if export_intensity>0&(t==1999|t==2000|t==2001)
replace indc_export_new=1 if export_intensity>0&(t>=2001)

bysort newid: egen indc_export1=max(indc_export)
bysort newid: egen indc_export2=max(indc_export_new)
*/
********************************************************************
replace did=post*random_tpu


gen lnabsG_gdp=ln(absG_gdp)

winsor2 tfp_op lnabsG_gdp lnage  finance2  lnkL rate , replace cuts(1 99) trim
winsor2 lnRD, replace cuts(0 99) trim
drop if VMPL<0

*drop if indc_export1==0&export_intensity>0
*******************************************************************************************************

* add tpu*1999 and tpu*2000: if firm expected the TPU decrease, they these two terms will be negative and significant.
reghdfe lnabsG did  Ltfp_op   Llnage  LlnkL Lfinance2 LlnRD Llnl   export_intensity ///
 Ltariff_input Ltariff_output post_kl_1998 Lhhi5_lns_ind Llnk_ind ,  ///
absorb(t newid ) cluster (ind4year)   
g _b_did=_b[did]
g _se_did=_se[did]

g _b_tfp=_b[Ltfp_op]
g _se_tfp=_se[Ltfp_op]

g _b_age=_b[Llnage]
g _se_age=_se[Llnage]

g _b_kl=_b[LlnkL]
g _se_kl=_se[LlnkL]

g _b_fin=_b[Lfinance2]
g _se_fin=_se[Lfinance2]

g _b_rd=_b[LlnRD]
g _se_rd=_se[LlnRD]


g _b_size=_b[Llnl]
g _se_size=_se[Llnl]

g _b_exp=_b[export_intensity]
g _se_exp=_se[export_intensity]
duplicates drop _b_did, force 
save "D:\Nanjing\2020\wage gap\Replication\mix\placebo`i'",replace
 }
 
 
 
	 use  "D:\Nanjing\2020\wage gap\Replication\mix\placebo1",clear
	 forvalue i=2/20{
	 append using  "D:\Nanjing\2020\wage gap\Replication\mix\placebo`i'"
	 }
	 gen tvalue_did=_b_did/_se_did

	 
	  gen tvalue_tfp=_b_tfp/_se_tfp
	  gen tvalue_size=_b_size/_se_size
	  gen tvalue_age=_b_age/_se_age
	  gen tvalue_kl=_b_kl/_se_kl
	  gen tvalue_fin=_b_fin/_se_fin
	  gen tvalue_rd=_b_rd/_se_rd
	   gen tvalue_exp=_b_exp/_se_exp
	   
	   
	   
	   
	   
	   
*---------------------------------------------------------------------------------------------
*---------------------------------------------------------------------------------------------
*---------------------------------------------------------------------------------------------
*---------------------------------------------------------------------------------------------


*----------------------------------------------------------

* Part II Columns 5-8: Capital Efficiency Gaps

*----------------------------------------------------------	   
	   
	   
cd "D:\Nanjing\2020\wage gap\Replication"   
	   
use "labor-basic-tpu-reg-1.dta",clear
gen VMPK=capitale*(y_ind_add1/k)

drop if VMPK<0




*1. generate capital category:
bysort id: gen indc_n=_n==1
gen m_k=k if indc_n==1
bysort id: egen M_k=max(m_k)

egen p1=pctile(M_k), p(25)
egen p2=pctile(M_k), p(50)
egen p3=pctile(M_k), p(75)
gen size_k=0
replace size_k=1 if M_k<=p1
replace size_k=2 if M_k>p1&M_k<p2
replace size_k=3 if M_k>p2&M_k<p3
replace size_k=4 if M_k>p3

 bysort t indc: egen agg_l=sum(n)
 gen l_s=n/agg_l
 
*2. generate average rental rate in each category:
bysort city ind4_adj QiuType size_k t: egen r_rate=sum(l_s*VMPK) if inv>0
*bysort county ind4_adj QiuType size_k t: egen r_rate=mean(VMPK) if inv>0


* 3. gap measured in capital:

gen gdp_def=1
replace gdp_def=1.077 if t==1999
replace gdp_def=1.077*1.085 if t==2000
replace gdp_def=1.077*1.085*1.083 if t==2001
replace gdp_def=1.077*1.085*1.083*1.091 if t==2002
replace gdp_def=1.077*1.085*1.083*1.091*1.10 if t==2003
replace gdp_def=1.077*1.085*1.083*1.091*1.10*1.201 if t==2004
replace gdp_def=1.077*1.085*1.083*1.091*1.10*1.201*1.114 if t==2005
replace gdp_def=1.077*1.085*1.083*1.091*1.10*1.201*1.114*1.127 if t==2006
replace gdp_def=1.077*1.085*1.083*1.091*1.10*1.201*1.114*1.127*1.142 if t==2007



gen gap_k=VMPK-r_rate
gen abs_G_k=abs(gap_k)
gen lnabs_k=log(abs_G_k)
*drop if export_intensity==1
gen ddd_export=did * d_export
* xtset newid t
 egen provyear=group(province  t)
 egen ind2year=group(ind2_adj  t)
 egen owneryear=group(QiuType  t)
 egen provowneryear=group(province QiuType  t)
 egen ind4year=group(ind4_adj  t)

capture drop ddd_export
gen indc_export=0
gen indc_export_new=0
replace indc_export=1 if export_intensity>0&(t==1999|t==2000|t==2001)
replace indc_export_new=1 if export_intensity>0&(t>=2001)

bysort newid: egen indc_export1=max(indc_export)
bysort newid: egen indc_export2=max(indc_export_new)

gen year1998=0
gen year1999=0
gen year2000=0
gen year2001=0
gen year2002=0
gen year2003=0
gen year2004=0
gen year2005=0
gen year2006=0
gen year2007=0
replace year1998=1 if t==1998
replace year2000=1 if t==2000
replace year1999=1 if t==1999
replace year2001=1 if t==2001
replace year2002=1 if t==2002
replace year2003=1 if t==2003
replace year2004=1 if t==2004
replace year2005=1 if t==2005
replace year2006=1 if t==2006
replace year2007=1 if t==2007

gen tpu1998=tpu_ind*year1998
gen tpu2000=tpu_ind*year2000
gen tpu1999=tpu_ind*year1999
gen tpu2001=tpu_ind*year2001
gen tpu2002=tpu_ind*year2002
gen tpu2003=tpu_ind*year2003
gen tpu2004=tpu_ind*year2004
gen tpu2005=tpu_ind*year2005
gen tpu2006=tpu_ind*year2006
gen tpu2007=tpu_ind*year2007
/*
bysort newid post: gen indc_n=_n==1
bysort newid: egen indc_exist=sum(indc_n)
*/

 

*egen ub1=pctile(absG),p(99)
*egen lb1=pctile(absG),p(1)

*replace did=0 if indc_export1==1
gen exp_post=indc_export1*post
gen exp_tpu=indc_export1*tpu
gen lnabsG_gdp=ln(absG_gdp)

winsor2 tfp_op lnabsG_gdp lnage  finance2  lnkL rate , replace cuts(1 99) trim
winsor2 lnRD, replace cuts(0 99) trim


bysort newid: egen indc=max(export_intensity)


*15.5 Column 5: pre-expectation effect:
* add tpu*1999 and tpu*2000: if firm expected the TPU decrease, they these two terms will be negative and significant.
reghdfe lnabs_k did tpu1999 tpu2000  Llnl   Ltfp_op   Llnage  LlnkL  LlnRD   export_intensity Lfinance2 ///
 Ltariff_input Ltariff_output post_kl_1998 Lhhi5_lns_ind Llnk_ind ,  ///
absorb(t newid ) cluster (ind4year)   
 
*-------------------------------------------------------------------------------------------------------------------

*15.6: Column 6 multiple year:
* add tpu*1999 and tpu*2000: if firm expected the TPU decrease, they these two terms will be negative and significant.
reghdfe lnabs_k   tpu1999 tpu2000 tpu2001 tpu2002 tpu2003 tpu2004 tpu2005 tpu2006 tpu2007 ///
Ltfp_op   Llnage  LlnkL Lfinance2 LlnRD Llnl   export_intensity ///
 Ltariff_input  Lhhi5_lns_ind Llnk_ind , ///
absorb(t newid) cluster (ind4year)   
*-------------------------------------------------------------------------------------------------------------------
 

 
 *15.7 Column 7: pre-period
 
cd "D:\Nanjing\2020\wage gap\Replication"   
	   
use "labor-basic-tpu-reg-1.dta",clear
drop tpu_ind
capture drop _merge
gen VMPK=capitale*(y_ind_add1/k)

drop if VMPK<0




*1. generate capital category:
bysort id: gen indc_n=_n==1
gen m_k=k if indc_n==1
bysort id: egen M_k=max(m_k)

egen p1=pctile(M_k), p(25)
egen p2=pctile(M_k), p(50)
egen p3=pctile(M_k), p(75)
gen size_k=0
replace size_k=1 if M_k<=p1
replace size_k=2 if M_k>p1&M_k<p2
replace size_k=3 if M_k>p2&M_k<p3
replace size_k=4 if M_k>p3

 bysort t indc: egen agg_l=sum(n)
 gen l_s=n/agg_l
 
*2. generate average rental rate in each category:
bysort city ind4_adj QiuType size_k t: egen r_rate=sum(l_s*VMPK) if inv>0
*bysort county ind4_adj QiuType size_k t: egen r_rate=mean(VMPK) if inv>0


* 3. gap measured in capital:

gen gdp_def=1
replace gdp_def=1.077 if t==1999
replace gdp_def=1.077*1.085 if t==2000
replace gdp_def=1.077*1.085*1.083 if t==2001
replace gdp_def=1.077*1.085*1.083*1.091 if t==2002
replace gdp_def=1.077*1.085*1.083*1.091*1.10 if t==2003
replace gdp_def=1.077*1.085*1.083*1.091*1.10*1.201 if t==2004
replace gdp_def=1.077*1.085*1.083*1.091*1.10*1.201*1.114 if t==2005
replace gdp_def=1.077*1.085*1.083*1.091*1.10*1.201*1.114*1.127 if t==2006
replace gdp_def=1.077*1.085*1.083*1.091*1.10*1.201*1.114*1.127*1.142 if t==2007



gen gap_k=VMPK-r_rate
gen abs_G_k=abs(gap_k)
gen lnabs_k=log(abs_G_k)
keep if t<=2000
merge m:1 ind4_adj t using "tpu_ind98-00"
egen ind4year=group(ind4_adj  t)
replace tpu_ind=log(tpu_ind)

gen lnabsG_gdp=ln(absG_gdp)
replace LlnRD=Llnk_ind
winsor2 tfp_op lnabsG_gdp lnage  finance2  lnkL rate , replace cuts(1 99) trim
drop if VMPL<0
 
 reghdfe lnabs_k   tpu_ind Ltfp_op   Llnage  LlnkL Lfinance2 LlnRD Llnl   export_intensity ///
 Ltariff_input  Lhhi5_lns_ind ,  ///
absorb(t newid) cluster (ind4year)   
 
 
 
 *****************************************************************************
*15.8 Column 8. random sample
cd "D:\Nanjing\2020\wage gap\Replication"   
	
forvalue i=1/100{






use "labor-basic-tpu-reg-1.dta",clear
gen VMPK=capitale*(y_ind_add1/k)

drop if VMPK<0




*1. generate capital category:
bysort id: gen indc_n=_n==1
gen m_k=k if indc_n==1
bysort id: egen M_k=max(m_k)

egen p1=pctile(M_k), p(25)
egen p2=pctile(M_k), p(50)
egen p3=pctile(M_k), p(75)
gen size_k=0
replace size_k=1 if M_k<=p1
replace size_k=2 if M_k>p1&M_k<p2
replace size_k=3 if M_k>p2&M_k<p3
replace size_k=4 if M_k>p3

 bysort t indc: egen agg_l=sum(n)
 gen l_s=n/agg_l
 
*2. generate average rental rate in each category:
bysort city ind4_adj QiuType size_k t: egen r_rate=sum(l_s*VMPK) if inv>0
*bysort county ind4_adj QiuType size_k t: egen r_rate=mean(VMPK) if inv>0


* 3. gap measured in capital:

gen gdp_def=1
replace gdp_def=1.077 if t==1999
replace gdp_def=1.077*1.085 if t==2000
replace gdp_def=1.077*1.085*1.083 if t==2001
replace gdp_def=1.077*1.085*1.083*1.091 if t==2002
replace gdp_def=1.077*1.085*1.083*1.091*1.10 if t==2003
replace gdp_def=1.077*1.085*1.083*1.091*1.10*1.201 if t==2004
replace gdp_def=1.077*1.085*1.083*1.091*1.10*1.201*1.114 if t==2005
replace gdp_def=1.077*1.085*1.083*1.091*1.10*1.201*1.114*1.127 if t==2006
replace gdp_def=1.077*1.085*1.083*1.091*1.10*1.201*1.114*1.127*1.142 if t==2007



gen gap_k=VMPK-r_rate
gen abs_G_k=abs(gap_k)
gen lnabs_k=log(abs_G_k)
merge m:1 ind4_adj using "D:\Nanjing\2020\wage gap\Replication\mix\random_sample"
egen ind4year=group(ind4_adj  t)
/*
drop if export_intensity==1
gen ddd_export=did * d_export
* xtset newid t
 egen provyear=group(province  t)
 egen ind2year=group(ind2_adj  t)
 egen owneryear=group(QiuType  t)
 egen provowneryear=group(province QiuType  t)
 egen ind4year=group(ind4_adj  t)

capture drop ddd_export
gen indc_export=0
gen indc_export_new=0
replace indc_export=1 if export_intensity>0&(t==1999|t==2000|t==2001)
replace indc_export_new=1 if export_intensity>0&(t>=2001)

bysort newid: egen indc_export1=max(indc_export)
bysort newid: egen indc_export2=max(indc_export_new)
*/
********************************************************************
replace did=post*random_tpu


gen lnabsG_gdp=ln(absG_gdp)

winsor2 tfp_op lnabsG_gdp lnage  finance2  lnkL rate , replace cuts(1 99) trim
winsor2 lnRD, replace cuts(0 99) trim


*drop if indc_export1==0&export_intensity>0
*******************************************************************************************************

* add tpu*1999 and tpu*2000: if firm expected the TPU decrease, they these two terms will be negative and significant.
reghdfe lnabs_k did  Ltfp_op   Llnage  LlnkL Lfinance2 LlnRD Llnl   export_intensity ///
 Ltariff_input Ltariff_output post_kl_1998 Lhhi5_lns_ind Llnk_ind ,  ///
absorb(t newid ) cluster (ind4year)   
g _b_did=_b[did]
g _se_did=_se[did]

g _b_tfp=_b[Ltfp_op]
g _se_tfp=_se[Ltfp_op]

g _b_age=_b[Llnage]
g _se_age=_se[Llnage]

g _b_kl=_b[LlnkL]
g _se_kl=_se[LlnkL]

g _b_fin=_b[Lfinance2]
g _se_fin=_se[Lfinance2]

g _b_rd=_b[LlnRD]
g _se_rd=_se[LlnRD]


g _b_size=_b[Llnl]
g _se_size=_se[Llnl]

g _b_exp=_b[export_intensity]
g _se_exp=_se[export_intensity]
duplicates drop _b_did, force 
save "D:\Nanjing\2020\wage gap\Replication\mix\placebo_k`i'",replace
 }
 
 
 
	 use  "D:\Nanjing\2020\wage gap\Replication\mix\placebo_k1",clear
	 forvalue i=2/20{
	 append using  "D:\Nanjing\2020\wage gap\Replication\mix\placebo_k`i'"
	 }
	 gen tvalue_did=_b_did/_se_did

	  gen tvalue_tfp=_b_tfp/_se_tfp
	  gen tvalue_size=_b_size/_se_size
	  gen tvalue_age=_b_age/_se_age
	  gen tvalue_kl=_b_kl/_se_kl
	  gen tvalue_fin=_b_fin/_se_fin
	  gen tvalue_rd=_b_rd/_se_rd
	   gen tvalue_exp=_b_exp/_se_exp
	   
	   
	   
	   
	   
	   
	   
